#测试用户注销
from BlogLoginTest import BlogLogin
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from common.Utils import BlogDriver

class BlogUserLogout:
    url=""
    driver=""
    def __init__(self):
        self.url=""
        self.driver=BlogDriver.driver

    def BlogLogoutTest(self,url):
        """
        博客列表页注销功能
        :return:
        """
        self.driver.get(url)
        self.driver.find_element(By.CSS_SELECTOR, "body > div.nav > a:nth-child(6)").click()

        # 判断一下退出后的页面url和页面的标题
        Quittitle = self.driver.title
        QuitUrl = self.driver.current_url

        print(Quittitle)
        print(QuitUrl)

        assert Quittitle == "博客登陆页"
        assert QuitUrl == "http://8.137.19.140:9090/blog_login.html"

        # 判断一下账号输入框和密码输入框的内容是否为空
        Quitusername = self.driver.find_element(By.CSS_SELECTOR, "#username").text
        Quitpassword = self.driver.find_element(By.CSS_SELECTOR, "#password").text
        print("Quitusername" + Quitusername)
        print("Quitpassword" + Quitpassword)
        assert Quitusername == ""  # 判断一下用户名输入框清空没有
        assert Quitpassword == ""  # 判断一下密码输入框清空没有

    def Login(self):
        user = "zhangsan"
        password = "123456"
        # 输入正确的账号和密码(输入前先清空输入框)
        BlogLogin().TestCase(user, password)